<template>
  <div>
    <el-container>
      <el-main>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span style="display:flex; justify-content: left;font-weight: bolder">收款人</span>
          </div>
            <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
              <el-form-item label="户名">
                <el-input v-model="j101.payeeName"></el-input>
              </el-form-item>
              <el-form-item label="账号">
                <el-input v-model="j101.payeeActno"></el-input>
              </el-form-item>
              <el-form-item label="银行">
                <el-input v-model="j101.payeeOpNetbrname"></el-input>
              </el-form-item>
              <el-form-item label-width="20px">
                <el-button icon="el-icon-search" plain type="primary" @click="openBankBranchDialog">
                  行名行号查询
                </el-button>
              </el-form-item>
            </el-form>
        </el-card>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span style="display:flex; justify-content: left;font-weight: bolder">转出账户</span>
          </div>
            <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
              <el-form-item label="户名">
                <el-input v-model="j101.payerName"></el-input>
              </el-form-item>
              <el-form-item label="账号">
                <el-input v-model="j101.payerActno"></el-input>
              </el-form-item>
              <el-form-item label="银行">
                <el-input v-model="j101.payerOpNetbrno"></el-input>
              </el-form-item>
            </el-form>
        </el-card>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span style="display:flex; justify-content: left;font-weight: bolder">转账金额</span>
          </div>
            <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
              <el-form-item label="金额">
                <el-input v-model="j101.amount"></el-input>
              </el-form-item>
              <el-form-item label="转账附言">
                <el-input v-model="j101.remarks"></el-input>
              </el-form-item>
            </el-form>
        </el-card>

        <el-row class="" style="display: flex; justify-content: space-around;margin-top: 30px;">
          <el-button style="width: 150px;" type="primary" @click="toPasswordVerify">确认转账</el-button>
        </el-row>
      </el-main>
    </el-container>

    <el-dialog title="请输入密码" :visible.sync="dialogFormVisible" width="280px">
      <el-form :model="form">
        <span>请输入6位交易密码</span>
          <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="accountTransCommit">确 定</el-button>
      </div>
    </el-dialog>
    <ibps-bank-branch-dialog  ref="ibpsBankBranchDialog" @confirm="confirmBankBranch"></ibps-bank-branch-dialog>
  </div>
</template>
<style>

</style>
<script>
import { ibps101send } from "@/api/ibps/ebank";
import IbpsBankBranchDialog from "@/views/components/IbpsBankBranchDialog";
export default {
  components: { IbpsBankBranchDialog },
  data(){
    return {
        options: [{
          value: 'gh1234',
          label: '工行'
        }, {
          value: 'pf4312',
          label: '浦发'
        }],
      dialogFormVisible:false,
      form:{
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      formLabelWidth:'120px',
      name:"",
      formLabelAlign: {
        name: '',
        region: '',
        type: ''
      },
      labelPosition:'',
      j101:{


        "payeeActno":"",
        "payeeName":"",
        "payeeOpNetbrno":"",
        "payeeOpNetbrname":"",
        "payeeStBrno":"",

        "payerActno":"6225881010029001",
        "payerActtype":"1",
        "payerName":"测试付款人名称",
        "payerOpCitycode":"1",
        "payerOpNetbrno":"313301008887",
        "payerStBrno":"313301008887",

        "amount":0,
        "remarks":"",

        // ------------------------
        // "pkgid":"12349999",
        // "acceptDate":"20230811",
        // "bizCode":"1",
        // "bizType":"0",
        // "btFlg":"false",
        // "chkDate":"20230811",
        // "chkRound":"1",
        // "chrgBr":"DEBT",
        // "clrDate":"20230811",
        // "curcd":"CNY",
        // "dltAmt":1234,
        "dtlCnt":1,
        // "e2eId":"e2eId",
        // "instrPrty":"NORM",
        //
        // "senderDatetime":"20230811121212",
        // "seqno":"1234",
        // "stMethod":"CLRG"
      },
    };
  },
  methods:{
    toPasswordVerify(){
      this.dialogFormVisible = true;
    },
    accountTransCommit(){
      console.log('accountTransCommit');

      ibps101send(this.j101).then((res) => {
        if(res.retStatus == 'SUCCESS'){
          console.log(res);
          this.$message({
            message: '转账成功',
            type: 'success',
            center: true,
          });
          this.dialogFormVisible = false;

        } else {
          this.$message({
            message: `转账失败: ${res.retStatus} - ${res.message}`,
            type: 'error',
            center: true,
          });
        }
      })

    },
    //行名行号查询
    openBankBranchDialog(fromFlag = "") {
      this.$refs.ibpsBankBranchDialog.show(fromFlag);
    },
    //行名行号返回
    confirmBankBranch(fromFlag, row) {
      console.log("row", row);
      // this.$set(this.submitParams, "receiver", row.brno);
      // this.$set(this.submitParams, "rcverDirect", row.bankCenter);
      // this.$set(this.submitParams, "rcverName", row.brname);
      this.j101.payeeOpNetbrno = row.brno;
      this.j101.payeeOpNetbrname = row.brname;
    },
  }
}
</script>
